package com.example.demo.task;

import org.redisson.api.RLock;

import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

public class RedisWatchDog extends TimerTask {

    private RLock  lock;
    private Integer waitTime;
    private TimeUnit timeUnit;
    public RedisWatchDog(Integer waitTime,TimeUnit timeUnit){
        this.waitTime = waitTime;
        this.timeUnit = timeUnit;
    }
    @Override
    public void run() {
        lock.expire(waitTime,timeUnit);
    }
    public Integer getWaitTime() {
        return waitTime;
    }

    public void setWaitTime(Integer waitTime) {
        this.waitTime = waitTime;
    }

    public TimeUnit getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(TimeUnit timeUnit) {
        this.timeUnit = timeUnit;
    }
    public RLock getLock() {
        return lock;
    }

    public void setLock(RLock lock) {
        this.lock = lock;
    }

}
